function food(el){
    this.el=el
    this.len=20
    this.foodObj=null
    this.foodX=0
    this.foodY=0
}
food.prototype.create=function() {
    let divObj=document.createElement('div')
    divObj.style.width=this.len+'px'
    divObj.style.height=this.len+'px'
    divObj.style.background='pink'
    divObj.style.position='absolute'

    //保存食物对象
    this.foodObj=divObj
    //在页面展示
    this.el.appendChild(divObj  )
    //移动食物
    this.move()


}
food.prototype.move=function(){
    let foodXMax =this.el.clientWidth / this.len -1
    let foodYMax =this.el.clientHeight / this.len -1

    this.foodX = Math.floor(Math.random()*(foodXMax-0+1)+0)*this.len
    this.foodY = Math.floor(Math.random()*(foodYMax-0+1)+0)*this.len

    this.foodObj.style.left=this.foodX+'px'
    this.foodObj.style.top=this.foodY+'px'
}